package com.example.demo.exception;

import com.example.demo.common.constant.ResultCode;
import com.example.demo.common.constant.ThrowFlag;

public class BusinessException extends RuntimeException {
    private final ResultCode resultCode;
    private final String message;
    private final String flag;

    public BusinessException(String message) {
        this.resultCode = null;
        this.message = message;
        this.flag = ThrowFlag.MESSAGE;
    }

    public BusinessException(ResultCode resultCode) {
        this.resultCode = resultCode;
        this.message = resultCode.getMessage();
        this.flag = ThrowFlag.CODE;
    }

    public BusinessException(String message, ResultCode resultCode) {
        this.resultCode = resultCode;
        this.message = message;
        this.flag = ThrowFlag.MESSAGE_CODE;
    }

    public ResultCode getResultCode() {
        return this.resultCode;
    }

    public String getMessage() {
        return this.message;
    }

    public String getFlag() {
        return this.flag;
    }
}
